﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mlr", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Mlr))]
    public class MlrSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMlr clazz;
        
        public MlrSerializer(IMlr clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("gametabid");
            if (clazz.Gametabid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametabid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametabid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gametabadc");
            if (clazz.Gametabadc!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametabadc))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametabadc");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gametabadst");
            if (clazz.Gametabadst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametabadst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametabadst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gametabadhno");
            if (clazz.Gametabadhno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametabadhno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametabadhno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("usestarttime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Usestarttime))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("useendtime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Useendtime))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="gametabid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>gametabid");
                }
                clazz.Gametabid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametabid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>gametabid", Reader.LocalName);
            }
            if (Reader.LocalName=="gametabadc") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>gametabadc");
                }
                clazz.Gametabadc = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametabadc")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>gametabadc", Reader.LocalName);
            }
            if (Reader.LocalName=="gametabadst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>gametabadst");
                }
                clazz.Gametabadst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametabadst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>gametabadst", Reader.LocalName);
            }
            if (Reader.LocalName=="gametabadhno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>gametabadhno");
                }
                clazz.Gametabadhno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametabadhno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>gametabadhno", Reader.LocalName);
            }
            if (Reader.LocalName=="usestarttime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>usestarttime");
                }
                clazz.Usestarttime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("usestarttime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>usestarttime", Reader.LocalName);
            }
            if (Reader.LocalName=="useendtime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mlr>useendtime");
                }
                clazz.Useendtime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("useendtime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mlr>useendtime", Reader.LocalName);
            }
        }
    }
}
